<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <link rel="stylesheet" href="../../lib/jq-module/zyupload/zyupload-1.0.0.min.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }

    </style>
</head>
<body>
<div class="layui-form layuimini-form" lay-filter="job-form">
    <div class="layui-form-item">
        <label class="layui-form-label">订单编号</label>
        <div class="layui-input-block">
            <input type="text" name="orderId" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">订单状态</label>
        <div class="layui-input-block">
            <input type="text" name="orderStatus" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">物流信息</label>
        <div class="layui-input-block">
            <input type="text" name="courierName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">下单时间</label>
        <div class="layui-input-block">
            <input type="text" name="joinTime" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">消费者昵称</label>
        <div class="layui-input-block">
            <input type="text" name="partnerName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商品名称</label>
        <div class="layui-input-block">
            <input type="text" name="goodsName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">玫丽专享价（元）</label>
        <div class="layui-input-block">
            <input type="text" name="unitPrice" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">购买数量</label>
        <div class="layui-input-block">
            <input type="text" name="buyQuantity" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">实付金额（元）</label>
        <div class="layui-input-block">
            <input type="text" name="payAmount" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">收货人姓名</label>
        <div class="layui-input-block">
            <input type="text" name="consigneeName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">手机号码</label>
        <div class="layui-input-block">
            <input type="text" name="consigneePhoneNum" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">收货地址</label>
        <div class="layui-input-block">
            <input type="text" name="consigneeAddress" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">线上服务商</label>
        <div class="layui-input-block">
            <input type="text" name="initiatorName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">线上服务商佣金（元）</label>
        <div class="layui-input-block">
            <!-- 此字段暂时无用，用来保存 服务商佣金（元） -->
            <input type="text" name="sceneId" disabled="disabled" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">区域服务商</label>
        <div class="layui-input-block">
            <!-- 此字段暂时无用，用来保存 服务商佣金（元） -->
            <input type="text" name="providerName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../../lib/common/common.js" charset="utf-8"></script>
<script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="../../js/lay-module/xm-select-master/dist/xm-select.js" charset="utf-8"></script>

<script>

    window.onload = function(){
        let recordId = GetQueryString("recordId");
        if(isNotNull(recordId)){
            init(recordId);
        }else{
            var iframeIndex = parent.layer.getFrameIndex(window.name);
            parent.layer.close(iframeIndex);
        }
    }

    /**
     * 初始化数据
     */
    function init(recordId) {
        $.ajax({
            type:"get",
            url:'/buying/get/'+recordId,
            dataType:'json',
            contentType: 'application/x-www-form-urlencoded',
            success:function(req){

                var addressObj = JSON.parse(req.data.address);

                var consigneeName = addressObj.Name?addressObj.Name:'';
                var consigneePhoneNum = addressObj.PhoneNum?addressObj.PhoneNum:'';
                var consigneeAddress = "";
                if(addressObj.Region){
                    consigneeAddress = addressObj.Region;
                    if(addressObj.StreetVillage){
                        consigneeAddress += "-" + addressObj.StreetVillage;
                        if(addressObj.Address){
                            consigneeAddress += " " + addressObj.Address;
                        }
                    }
                }
                layui.use(['form'], function () {
                    let form = layui.form
                    form.val('job-form',{
                        "orderId": req.data.orderId,
                        "orderStatus": req.data.orderStatus,
                        "courierName":  req.data.courierName + " " + req.data.courierNumber,
                        "joinTime": req.data.joinTime,
                        "partnerName": req.data.partnerName + "（" + req.data.partnerId + "）",
                        "goodsName": req.data.goodsName + "（" + req.data.goodsNo + "）",
                        "unitPrice": req.data.unitPrice,
                        "buyQuantity": req.data.buyQuantity,
                        "payAmount": req.data.payAmount,
                        "consigneeName": consigneeName,
                        "consigneePhoneNum": consigneePhoneNum,
                        "consigneeAddress": consigneeAddress,
                        "initiatorName": req.data.initiatorName + "（" + req.data.initiatorId + "）",
                        "sceneId": req.data.sceneId,
                        "providerName" : req.data.provider.nickName + '-NO.' + req.data.provider.providerId
                    });
                })
            },
            error:function(e){
                layer.msg("数据有误");
            }
        })
    }
</script>
</body>
</html>